<?php use_javascript('datapiker.js');?>
<?php use_stylesheet('datepicker.css');?>
<div class="title"><?php echo __('Список оплат')?></div>

<?php $form = new PaymentFormFilter(); ?>
<?php 

 $form->setDefaults(array(
    	'payment_id' => sfContext::getInstance()->getRequest()->getParameter('payment_filters[payment_id]'),
    	'level_id' => sfContext::getInstance()->getRequest()->getParameter('payment_filters[level_id]'),
        'date_from' => sfContext::getInstance()->getRequest()->getParameter('payment_filters[date_from]'),
        'date_to' => sfContext::getInstance()->getRequest()->getParameter('payment_filters[date_to]'),

  	
    ));

?>

<form action="<?php echo url_for('payment/index')?>" method="GET">
<table>
<tr>
<td><?php echo $form['payment_id']->render()?></td>
<td><?php echo $form['level_id']->render()?></td>
<td>
    с
    <?php echo $form['date_from']->render()?>
    по
    <?php echo $form['date_to']->render()?>
</td>
<td><input type="submit" value="<?php echo __('Фильтр')?>"></td>
</tr>
</table>
</form>

<?php if ($payment->getResults()): ?>
	<table class="table1" width="100%">
	         <tr>
	         <th><?php echo __('User')?></th>
			<th><?php echo __('Дата')?></th>
			<th><?php echo __('Описание')?></th>
			<th><?php echo __('Направление')?></th>
			<th><?php echo __('Сумма')?></th>
			</tr>
		 <?php foreach ($payment->getResults() as $p): ?>
		 <tr>
		 <td><?php echo $p->getsfGuardUserRelatedByPaymentId() ?></td>
		 <td><?php echo format_date($p->getCreatedAt(),'d')?></td>
		 <td><?php echo $p->getLevelPayment() ?></td>
		 <td><?php echo $p->getDirectionStr() ?></td>
		 <td><?php echo $p->getSumma() ?></td>
		 </tr>
		 <?php endforeach; ?>
		 <tr>
		 <th colspan="4"><?php echo __('Итого')?>:</th>
		 <th><?php echo $suma?></th>
		 </tr>
	</table>
	<?php include_partial('global/common/'.sfConfig::get('app_name').'/pager', array('pager'=>$payment)) ?>

<?php else: ?>

 
 <?php echo __('Результатов не найдено')?>
 
<?php endif ?>


      <script type="text/javascript">
  $(document).ready(function(){
    // ---- Календарь -----
    $('#payment_filters_date_from').attachDatepicker();
    $('#payment_filters_date_to').attachDatepicker();
    // ---- Календарь -----
  });
  </script>